So to do our server side purchasing, let's go to our shop and use that script.
So if I go up here, I got my shop, opened that up, and then I have this activate shop script.
That's where we open it up.
But it's really convenient because we have replicated storage, We have our shop.
Ray and I need to catch the event coming from the client, from the shop.
Ray So notice we sent the request to open the shop up on this side and then we use the same remote event
to capture the sale coming back, right?
The server side event.
That's kind of convenient.
You could use remote events over and over.
If you were really clever, you'd only need one.
But I'm not that clever.
I like to make remote events and name them specifically for their things that I keep track of.
I'm a little easier.
I'm going to do the shop re dot on server event.
So when that when that when we capture that event, we are going to connect to an anonymous function.
We will get the player first.
So in a client sends a remote event, player always comes first.
If you remember we just sent the item name and the item price, so I'll get my item name and the item
price after the player.
A lot of people do the remote events and they are looking for like the name here and they're getting
the player and they're getting an error and it's kind of weird.
They don't know why, but that's it.
The player is always going to be first, so let's get the item with the item name.
We have replicated storage.
We declared it above Wait for child.
Remember, we have our simple pistol and our fabulous lemon inside replicated storage we will look for.
Also have to do is put item name in there.
It should either be simple pistol or fabulous lemon.
Right now let's check to see if we actually got the item.
If item, then we will clone the item.
I'll call it item clone item, Colon, clone Aereo.
And then let's put the item clone
parent equal to our players backpack.
So that essentially puts the item in the backpack.
All right.
And now this is where we subtract our points from our leaderboard from our leader stats.
So let's get a value for that price because it's coming over as text.
I'm going to do a two number and then what do we call it?
Item price.
And we can do a little bit of a check for security.
You should you should you should actually check the price on this side.
But what I'm going to do is I'm just going to do an F statement.
I do if price is less than or equal to our highest priced item, which is 2000 and price is greater
than or equal to 1000, which is our lowest priced item, then we'll make the purchase.
So they could still hack the system, but they're not going to get that much from it.
So let's say player leader stats, dot points, dot value.
Minus equals price to have a price.
There we go.
Price.
All right, let's try this out so you don't even need this.
If statement will work without it.
It's just.
This is just a check in case someone hacks your game.
They don't give themselves a million.
A million points.
We'll go to output window check for errors.
Should we squish this up so that our window looks pretty good?
Here we go.
Simple pistol.
Bye.
All right.
So it subtracted our points.
Not enough money.
Oh, my goodness.
So I've got to go get some money.
I'm going to pause the video.
Okay, I'm back.
I didn't actually get coins.
I went in the game manager gave myself some some extra money.
So let's go and click our little bell.
Simple pistol.
Oh, let's look at our output window.
And then let's make our windows so that it doesn't look weird.
They're going to hit by.
There we go.
We got a pistol.
We should clear this out, though.
We should also check to make sure not to do double purchases, because right now we don't have a cell
back.
We'll have to work on that at some point.
So then I have my fabulous lemon.
That's 2000 points.
Oh, not enough money.
And we have to get our queuing service to put something up saying we don't have enough money yet, but
we basically have a functioning store.
All right.
So there you go.
That's the minimum requirement for a store.
All right.
I will see you in the next video.
We'll do a little bit of cleanup of this.